package com.jokesoft.supermanager.common.dto;

import java.util.List;

import com.jokesoft.supermanager.common.services.Address;

public class PersonDto {

    private final String firstName;
    private final String lastName;
    private final String role;
    private final Long personId;
    private final List<Address> addressList;

    public PersonDto(String firstName, String lastName, String role, Long personId, List<Address> addresList) {
        super();
        this.firstName = firstName;
        this.lastName = lastName;
        this.role = role;
        this.personId = personId;
        this.addressList = addresList;
    }

    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public String getRole() {
        return role;
    }

    public Long getPersonId() {
        return personId;
    }

    public List<Address> getAddressList() {
        return addressList;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((addressList == null) ? 0 : addressList.hashCode());
        result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
        result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
        result = prime * result + ((personId == null) ? 0 : personId.hashCode());
        result = prime * result + ((role == null) ? 0 : role.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        PersonDto other = (PersonDto) obj;
        if (addressList == null) {
            if (other.addressList != null)
                return false;
        } else if (!addressList.equals(other.addressList))
            return false;
        if (firstName == null) {
            if (other.firstName != null)
                return false;
        } else if (!firstName.equals(other.firstName))
            return false;
        if (lastName == null) {
            if (other.lastName != null)
                return false;
        } else if (!lastName.equals(other.lastName))
            return false;
        if (personId == null) {
            if (other.personId != null)
                return false;
        } else if (!personId.equals(other.personId))
            return false;
        if (role == null) {
            if (other.role != null)
                return false;
        } else if (!role.equals(other.role))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "PersonDto [firstName=" + firstName + ", lastName=" + lastName + ", role=" + role + ", personId="
                + personId + ", addressList=" + addressList + "]";
    }

}
